package com.shrct.businessprocess.customerservice.proxy;

import com.google.gwt.user.client.rpc.IsSerializable;
import com.shrct.businessprocess.customerservice.proxy.RCFaultReportAction;

public class RCFaultReportManager implements IsSerializable {
  public static Boolean isActionValid(final RCFaultReportAction action, final String state) {
    if(action==null||state==null) return false;
    switch(action){
    	case processReport:{
    		return "reported".equals(state);
    	}
    	case _delete:{
    		return "reported".equals(state);
    	}
    	case requireRMA:{
    		return "processed".equals(state);
    	}
    	case repairPerformed:{
    		return "processed".equals(state);
    	}
    	case pend:{
    		return "processed".equals(state)||"waiting4rma".equals(state);
    	}
    	case upgrade2Level:{
    		return "reported".equals(state)||"processed".equals(state);
    	}
    	case RMAPerformed:{
    		return "waiting4rma".equals(state);
    	}
    	case startDeviceRMA:{
    		return "waiting4rma".equals(state);
    	}
    	case finishDeviceRMA:{
    		return "finished".equals(state)||"waiting4rma".equals(state);
    	}
    	case resume:{
    		return "pending".equals(state);
    	}
    	case appendInfo:{
    		return "reported".equals(state)||"processed".equals(state)||"waiting4rma".equals(state)||"processed".equals(state)||"pending".equals(state)||"finished".equals(state);
    	}
    	case assign:{
    		return "waiting4rma".equals(state)||"processed".equals(state)||"pending".equals(state);
    	}
    	case engineerReport:{
    		return "waiting4rma".equals(state)||"processed".equals(state)||"pending".equals(state);
    	}
    	default:
    		return false;
    }
    
  }
  
  public static Boolean isActionValid(final RCFaultReportAction action, final Enum<?> state) {
    return isActionValid(action,state.name());
    
  }
}
